package com.wanmait.employment.manageController;

import com.github.pagehelper.PageInfo;
import com.wanmait.employment.entity.CompanyWelfareLabelBasics;
import com.wanmait.employment.service.CompanyWelfareLabelBasicsService;
import com.wanmait.employment.util.AjaxResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("/manage/CompanyWelfareLabelBasics/")
@CrossOrigin
public class CompanyWelfareLabelBasicsController {
    @Resource
    private CompanyWelfareLabelBasicsService companyWelfareLabelBasicsService;

    @GetMapping("list")
    @ResponseBody
    public AjaxResult List(String title, Integer pageNum, Integer pageSize){
        PageInfo<CompanyWelfareLabelBasics> companyWelfareLabelBasics=companyWelfareLabelBasicsService.selectList(title,pageNum,pageSize);
        return AjaxResult.success("",companyWelfareLabelBasics);
    }

    @PostMapping("update")
    public AjaxResult update(@RequestBody CompanyWelfareLabelBasics companyWelfareLabelBasics){
        if (companyWelfareLabelBasics.getId()!=null){
            companyWelfareLabelBasicsService.update(companyWelfareLabelBasics);
            return AjaxResult.success("修改成功");
        }
        else {
            companyWelfareLabelBasicsService.insert(companyWelfareLabelBasics);
            return AjaxResult.success("添加成功");
        }
    }
    @GetMapping("delete")
    public AjaxResult delete(Integer id){
        companyWelfareLabelBasicsService.delete(id);
        return  AjaxResult.success("删除成功");
    }

}
